#!/usr/bin/env python
# -*- coding: utf-8 -*-

import time
import signal
import sys
import os

def signal_handler(signum, frame):
    print(f"Hello World script received signal {signum}, exiting gracefully...")
    sys.exit(0)

# 注册信号处理器
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)

def main():
    print(f"Hello World script started! PID: {os.getpid()}")
    print("This is a test script for the dual service system.")
    
    try:
        for i in range(60):  # 运行60秒
            print(f"Hello World! Count: {i}")
            time.sleep(1)
    except KeyboardInterrupt:
        print("Interrupted by keyboard")
    finally:
        print("Hello World script finished!")

if __name__ == '__main__':
    main()